package com.shilei.singleton;

/**
 * @description: 静态内部类方法
 *     jvm保证单例
 *     加载外部类时不会加载内部类，这样可以实现懒加载
 * @author: 81271
 * @date: 2020-04-12 10:02
 */
public class Mgr04 {
    private Mgr04() {
    }

    private static class Mgr04Holder {
        private static final Mgr04 INSTANCE = new Mgr04();
    }

    public static Mgr04 getInstance() {
        return Mgr04Holder.INSTANCE;
    }


    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(() -> System.out.println(Mgr04.getInstance().hashCode())).start();
        }
    }
}
